package com.rickie.executor.query;

import com.alibaba.cola.dto.SingleResponse;
import com.rickie.convertor.CargoDTOConvertor;
import com.rickie.model.aggregates.Cargo;
import com.rickie.gateway.CargoBookingGateway;
import com.rickie.dto.data.CargoDTO;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;

/**
 * @author rickie
 * @version 1.0.0
 * @ClassName CargoByBookingIdQryExe.java
 * @Description 货物查询处理程序
 * @createTime 2021年06月19日 18:17:00
 */
@Component
public class CargoByBookingIdQryExe {
    @Resource
    private CargoBookingGateway cargoBookingGateway;

    public SingleResponse<CargoDTO> execute(String bookingId){
        Cargo cargo = cargoBookingGateway.getByBookingId(bookingId);
        CargoDTO cargoDTO = CargoDTOConvertor.toDTO(cargo);
        return SingleResponse.of(cargoDTO);
    }
}